<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>待处理订单列表</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#importBox_goods").hide();
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function close_imbox(){
			$("#importBox_goods").hide();
		}
		
		function shows(a,b,c,d){
			$("#yumoney").text("￥"+(c*100/1000).toFixed(2));
			$(".chaMoney").val("0.00");
			$("#freight").val((c*100/1000).toFixed(2));
			$("#cha").text("差价:￥0.00");
			$("#userid").val(a);
			$("#orderCode").val(b);
			$("#orderId").val(d);
			$.ajax({
				type:"post",
				url:"${ctx}/sys/orders/kYong",
				dataType:"json",
				data:{"id":a},
			    success:function(e){
			    	if(e!=null){
			    		$("#kyMoney").val(e.kyong);
			    	}
			    }
				
			})
			$("#importBox_goods").show();
		}
		 
		function confirm_imbox(){
			var yuFei=$("#yumoney").text();
			
			var feig=$("#freight").val();
			var ys=yuFei.length-1;
			var st=yuFei.substr(1,ys) ;
			var ky=$("#kyMoney").val();

			if(ky!=0){
			var stgs=parseFloat(ky)+parseFloat(st);
			if(feig>stgs){
				 showTip("额度不够!", "", 3000, 0);
				 $("#importBox_goods").hide();
				return false;
			}else{
				 $("#importBox_goods").hide();
				$("#forms").submit();
			}
			}else{
				showTip("额度不够!", "", 3000, 0);
				 $("#importBox_goods").hide();
				 return false;
			}
			
		}
		
		function yunFei(){
			var fe=$("#freight").val();
			/* var re = /^\d+(?=\.{0,1}\d+$|$)/ ;
			if($.trim(fe).test()) */
			var freight=parseFloat($("#freight").val());
			var yuFei=$("#yumoney").text();
			var ys=yuFei.length-1;
			var st=yuFei.substr(1,ys) ;
			var chas=(parseFloat(st)-parseFloat(freight)).toFixed(2);
			$("#cha").text("差价:￥"+chas);
			$("#chaMoney").val(chas);
		}
		function wuLiu(v){
			window.location.href="${ctx}/sys/orders/wuInformatin?orderCode="+v;
	 	}
	</script>
	
	<style>
		#importBox_goods{
			position:fixed;
			padding:0 15px;
			width:400px;
			height:200px;
			background:#FFF;
			top:10%;
			left:25%;
			margin:0 auto;
			border:1px solid #CCC;
			box-shadow:3px 3px 10px 4px #DDD;
			z-index: 9999;
			
		}
		#importBox_goods .ib_title{
			margin-bottom:35px;
		}
		.form-search .ul-form li label{
			width: 85px;
		}
	</style>
</head>
<body>
    <div id="importBox_goods" class="hide" style="width:360px;height:220px;">
			<div class='ib_title'>
			 <h3>运费金额</h3>
			</div>
			 <form action="${ctx }/sys/orders/addFreight" method="post" id="forms">
					<label>预扣运费:<span id="yumoney"></span></label><br><br>
					<label>实付运费:<input name="freight" id="freight" onchange="yunFei()" style="width:80px;margin-right:10px;" type="number"><span id="cha"> </span></label>
					<input type="hidden" name="userId" id="userid" type="hidden"/>
					<input type="hidden" name="orderCode" id="orderCode" type="hidden"/>
					<input type="hidden" name="chaMoney" id="chaMoney" class="chaMoney">
					<input  name="kyMoney" id="kyMoney" type="hidden"/>
					<input  name="orderId" id="orderId" type="hidden"/>
					
			    </form>
					
					<input id="btnCancel" class="btn" type="button" style='margin-left:220px;' value="确定" onclick="confirm_imbox()"/>
					<input id="btnCancel" class="btn" type="button" style='margin-left:5px;' value="取消" onclick="close_imbox()"/>
	</div>
	
	
	
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/orders/handleOrderList">待处理订单列表</a></li>
		<%-- <shiro:hasPermission name="sys:orders:edit"><li><a href="${ctx}/sys/orders/form">订单管理添加</a></li></shiro:hasPermission> --%>
	</ul>
	<form:form id="searchForm" modelAttribute="orders" action="${ctx}/sys/orders/handleOrderList" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
		
		    <li><label>订单编号：</label>
				<form:input path="code" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			 <li><label>下单时间：</label>
				<input name="startTime" type="text" readonly="readonly" placeholder="开始时间" class="input-medium Wdate " 
					value="<fmt:formatDate value="${order.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/>"
			         onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			     &nbsp;&nbsp;&nbsp;&nbsp;
			     <input name="endTime" type="text" readonly="readonly" placeholder="结束时间" class="input-medium Wdate " 
					value="<fmt:formatDate  value="${order.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/>"
			     onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> 
			</li> 
			<li><label>下单门店：</label><form:select id="buyStoreCode" path="buyStoreCode" class="input-medium">
			<form:option value="" label="下单门店"/>
			<form:options items="${store}" htmlEscape="false" itemValue="code" itemLabel="cnName"/>
			</form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>序号</th>
				<th>订单编号</th>
				<th>下单时间</th>
				<th>用户类型</th>
				<th>下单用户</th>
				<th>订单金额</th>
				<th>下单门店</th>
				<th>状态</th>
				<shiro:hasPermission name="sys:orders:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="orders" varStatus="status">
			<tr>
			    <td>${status.index+1}</td>
			    <td><a href="${ctx}/sys/orders/form?id=${orders.id}&tagUrl=${ctx}/sys/orders/handleOrderList&tagName=2">${orders.code }</a></td>
				<td>
					<fmt:formatDate value="${orders.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>${fns:getDictLabel(orders.userType, 'user_type', '')}</td>
				<td>
				<c:if test="${orders.userType=='1' }">
				${orders.userName }
				</c:if>
				<c:if test="${orders.userType=='2' }">
				${orders.company }
				</c:if>
				</td>
				<td>${orders.payMoney }</td>
				<td>${orders.buyStoreName }</td>
				<td>${fns:getDictLabel(orders.state, 'orders_state', '')}</td>
			
				<shiro:hasPermission name="sys:orders:edit"><td>
    				<c:if test="${orders.state==2 }">
    				 <a href="${ctx }/sys/orders/deliverGoods?code=${orders.code}&storeCode=${orders.buyStoreCode}">发货</a>
    				</c:if>
    				<c:if test="${orders.state==3 }">
    				 <a href="${ctx }/sys/orders/deliverGoods?code=${orders.code}&storeCode=${orders.buyStoreCode}">发货</a>
    				 <a href="javascript:void(0);" onclick ="wuLiu(${orders.code })">物流追踪</a>
    				</c:if>
    				<c:if test="${orders.state==4  }">
    				  <c:if test="${orders.transportType==1}"> 
    				 <a href="javascript:void(0)" onclick="shows(${orders.user},${orders.code },${orders.money },${orders.id })">确认运费</a>
    				 </c:if>
    				  <a href="javascript:;" onclick ="wuLiu(${orders.code })">物流追踪</a>
    				 </c:if>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>